package net.bwie.realtime.jtp.dws.log.function;

import net.bwie.realtime.jtp.dws.log.bean.PageViewBean;
import org.apache.flink.api.common.functions.ReduceFunction;

public class PageViewReportReduceFunction implements ReduceFunction<PageViewBean> {


    @Override
    public PageViewBean reduce(PageViewBean tmp, PageViewBean bean) throws Exception {
        /*
           tmp：表示增加计算中间结果；bean：表示当前窗口中每条数据
         */
        // 1增量计算：各个指标值相加
        tmp.setPvCount(tmp.getPvCount() + bean.getPvCount());
        tmp.setPvDuringTime(tmp.getPvDuringTime() + bean.getPvDuringTime());
        tmp.setUvCount(tmp.getUvCount() + bean.getUvCount());
        tmp.setSessionCount(tmp.getSessionCount() + bean.getSessionCount());

        // 2 返回结果
        return tmp;
    }
}
